//
//  XDLMHomeViewController.m
//  xindailianmeng
//
//  Created by 许佳奇 on 17/1/17.
//  Copyright © 2017年 xindailianmeng.cn. All rights reserved.
//

#import "XDLMHomeViewController.h"
#import "ScrollView.h"
#import "XDLMUIFactory.h"
#import "XDLMLoginViewController.h"
#import "AFHTTPSessionManager+POST.h"

#import "XDLMNavigatonController.h"
#import "XDLMBannerModel.h"
#import "SDImageCache.h"
#import "XDLMUIFactory.h"
#import "XDPublicViewController.h"

#import "XDAssetDetailsViewController.h"
#import "XDLMTotalIncomeViewController.h"
#import "XDLMMdShowProcess.h"
#import "XDLMBannerInfoViewController.h"
#import "XDLMMiiddleWebViewController.h"


#define LINECOLOR [UIColor colorWithRed:5.0/255.0 green:0/255.0 blue:1.0/255.0 alpha:1]
#define TCOLOR [UIColor colorWithRed:187.0/255.0 green:147.0/255.0 blue:115.0/255.0 alpha:1]
#define TRANSLINECOLOR [UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1]
#define LeftH (kScreenH - 200*kscale)/3//去除登录按钮剩余高度/3
@interface XDLMHomeViewController ()<scrollImageDidDelegate>

@property (nonatomic, strong) ScrollView *scView;
@property (nonatomic, strong) NSMutableArray *bannerDataSource;
@property (nonatomic, strong)XDLMMdShowProcess *process;
@property (nonatomic, strong)UIImageView        *InfoImage;
@property (nonatomic, strong)NSString           *ctTime;

@end

@implementation XDLMHomeViewController
{
    UIScrollView *_backView;//背景view
    BOOL _isLogin;//判断是否登录
    UILabel *_assetLab;//显示资产的lab
    UILabel *_incomeLab;//显示总收益的lab
    UIImageView *_circleImage;
    
    UIBarButtonItem *_rightItem;
   
}

//请求banner图
- (void)loadBannerData
{
    [self.process showHud];
    NSDictionary *param = @{@"method":@"index"};
    [AFHTTPSessionManager POSTWithParams:param success:^(NSURLSessionDataTask *task, id responseObject)
    {
        [self.process hideHud];
        if ([responseObject[@"code"] isEqualToString:@"100000"]) {
            NSLog(@"===%@",responseObject);
            NSMutableArray *array = responseObject[@"result"][@"appBannerList"];
            self.ctTime = responseObject[@"result"][@"ctime"];
//            NSMutableArray *array2 = responseObject[@"result"][@"newbieList"];
            NSDictionary *array3 = responseObject[@"result"][@"yxjhUrl"];
//            NSDictionary *dic1 = array[0];
//            [dic1 objectForKey:@"banpic"];
//            NSDictionary *dic2 = array2[0];
//            [dic2 objectForKey:@"banpic"];
//            NSDictionary *dic3 = array3[0];
//            [dic3 objectForKey:@"banpic"];
//            NSArray *array4 = [NSArray arrayWithObjects:[dic1 objectForKey:@"banpic"],[dic2 objectForKey:@"banpic"],[dic3 objectForKey:@"banpic"], nil];
            
//            NSDictionary *dd = [array objectAtIndex:3];
//            UIImage *InfoImg = [UIImage imageNamed:@"youxuanafter"];
//            [self.InfoImage sd_setImageWithURL:[NSURL URLWithString:dd[@"newbieUrl"]] placeholderImage:nil];
            
            
            //rx[self.bannerDataSource addObject:bannerModel];
            for (NSDictionary *dic in array) {
                XDLMBannerModel *bannerModel = [[XDLMBannerModel alloc] initWithDictionary:dic error:nil];
                
                [self.scView.imageUrlArray addObject:dic[@"banpic"]];
                [self.bannerDataSource addObject:dic[@"bannerUrl"]];
                
            }
            
//            [self.scView.imageUrlArray addObject:[dic1 objectForKey:@"banpic"]];
            NSLog(@"imageUrlArray===%@",self.scView.imageUrlArray);
            [self setRightTabbarItem];
            [self.scView reloadData];
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error)
    {
        [self setRightTabbarItem];
        [self.process hideHud];
        NSLog(@"%@",error);
    }];
}
- (void)addview
{
    
    _backView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
    _backView.backgroundColor = [UIColor whiteColor];
    _backView.contentOffset = CGPointMake(0, 0);
    _backView.contentSize = CGSizeMake(kScreenW, kScreenH*2);
    _backView.pagingEnabled = YES;
//    _backView.bounces = NO;
    [self.view addSubview:_backView];
    
    [self addhotbtn];
    [self setScrollView];
    [self setSixBtnUI];
    
}
//设置注册即送800处的button、登录注册按钮、下部分布局
- (void)addhotbtn
{
    if (_isLogin == NO) {
        UIButton *hotBtn = [[UIButton alloc] initWithFrame:CGRectMake(15, 189 * kscale, kScreenW-30, 110 * kscale)];
        [hotBtn setBackgroundImage:[UIImage imageNamed:@"loginand"] forState:UIControlStateNormal];
        [hotBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [_backView addSubview:hotBtn];
        
        //登录注册按钮
        UIButton *loginBtn = [[UIButton alloc] initWithFrame:CGRectMake((kScreenW-244* kscale)/2, 273 * kscale, 244* kscale, 45 * kscale)];
        [loginBtn setBackgroundImage:[UIImage imageNamed:@"logingold"] forState:UIControlStateNormal];
        [loginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [_backView addSubview:loginBtn];
        
        UIImage *circleImg = [UIImage imageNamed:@"halfcircle"];
        _circleImage = [[UIImageView alloc] initWithImage:circleImg];
        _circleImage.frame = CGRectMake(0, 338* kscale, kScreenW, kScreenH - 338* kscale);
        [_backView addSubview:_circleImage];
        
        UIImage *InfoImg = [UIImage imageNamed:@"bottom"];
        UIImageView *InfoImage = [[UIImageView alloc] initWithImage:InfoImg];
        InfoImage.frame = CGRectMake((kScreenW - 245*kscale)/2, kScreenH - 183*kscale- 130*kscale, 245*kscale, 183*kscale);
        [_backView addSubview:InfoImage];

    }
    else
    {
        _backView.scrollEnabled = NO;
        UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 90*kscale)];
        [_backView addSubview:topView];
        
        UIImage *zhinengImg = [UIImage imageNamed:@"zhineng"];
        UIImageView *zhiImgView = [[UIImageView alloc] initWithImage:zhinengImg];
        zhiImgView.frame = CGRectMake(19, 15*kscale, 66*kscale, 61*kscale);
        [topView addSubview:zhiImgView];
        
        _assetLab = [[UILabel alloc] initWithFrame:CGRectMake(90, 23*kscale, 130*kscale, 30*kscale)];
        _assetLab.text = @"969999.82元";
        _assetLab.textColor = TCOLOR;
        _assetLab.font = [UIFont systemFontOfSize:FONTSIZE22];
//        _assetLab.backgroundColor = [UIColor yellowColor];
        _assetLab.textAlignment = NSTextAlignmentRight;
        _assetLab.attributedText = [self changeLabelWithText:_assetLab.text];
        _assetLab.userInteractionEnabled = YES;
        UITapGestureRecognizer *assetGestrue = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(totalBtnClick)];
        [_assetLab addGestureRecognizer:assetGestrue];
        [topView addSubview:_assetLab];
        
        _incomeLab = [[UILabel alloc] initWithFrame:CGRectMake(kScreenW - 149*kscale, 23*kscale, 130*kscale, 30*kscale)];
        _incomeLab.text = @"969999.82元";
        _incomeLab.textColor = TCOLOR;
        _incomeLab.font = [UIFont systemFontOfSize:FONTSIZE22];
//        _incomeLab.backgroundColor = [UIColor yellowColor];
        _incomeLab.textAlignment = NSTextAlignmentRight;
        _incomeLab.attributedText = [self changeLabelWithText:_incomeLab.text];
        _incomeLab.userInteractionEnabled = YES;
        UITapGestureRecognizer *incomeGestrue = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(accumulatedBtnClick)];
        [_incomeLab addGestureRecognizer:incomeGestrue];
        [topView addSubview:_incomeLab];
        
//        UILabel *totalBtn = [[UILabel alloc] initWithFrame:CGRectMake(180*kscale, 53*kscale, 40*kscale, 20*kscale)];
//        totalLab.text = @"总资产";
//        totalLab.textColor = TCOLOR;
//        totalLab.font = [UIFont systemFontOfSize:FONTSIZE14];
//        [topView addSubview:totalLab];
        UIButton *totalBtn = [[UIButton alloc] initWithFrame:CGRectMake(170*kscale, 58*kscale, 40*kscale, 11*kscale)];
//        [totalBtn setTitle:@"总资产" forState:UIControlStateNormal];
//        [totalBtn setTitleColor:TCOLOR forState:UIControlStateNormal];
//        totalBtn.titleLabel.font = [UIFont systemFontOfSize:FONTSIZE14];
        [totalBtn setBackgroundImage:[UIImage imageNamed:@"zongzichan"] forState:UIControlStateNormal];
        [totalBtn addTarget:self action:@selector(totalBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [topView addSubview:totalBtn];
        
        UIButton *accumulatedBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW - 84*kscale, 58*kscale, 50*kscale, 11*kscale)];
//        [accumulatedBtn setTitle:@"累计收益" forState:UIControlStateNormal];
//        [accumulatedBtn setTitleColor:TCOLOR forState:UIControlStateNormal];
//        accumulatedBtn.titleLabel.font = [UIFont systemFontOfSize:FONTSIZE14];
        [accumulatedBtn setBackgroundImage:[UIImage imageNamed:@"leijishouyi"] forState:UIControlStateNormal];
        [accumulatedBtn addTarget:self action:@selector(accumulatedBtnClick) forControlEvents:UIControlEventTouchUpInside];
        [topView addSubview:accumulatedBtn];
        
        UIImage *circleImg = [UIImage imageNamed:@"afterLogin"];
        _circleImage = [[UIImageView alloc] initWithImage:circleImg];
        _circleImage.frame = CGRectMake(0, 300* kscale, kScreenW, kScreenH - 300* kscale);
        [_backView addSubview:_circleImage];
        
        UIImage *InfoImg = [UIImage imageNamed:@"youxuanafter"];
        self.InfoImage = [[UIImageView alloc] initWithImage:InfoImg];
        self.InfoImage.frame = CGRectMake((kScreenW - 255*kscale)/2, kScreenH - 186*kscale- 130*kscale, 255*kscale, 186*kscale);
        self.InfoImage.userInteractionEnabled = YES;
        _backView.userInteractionEnabled = YES;
        [_backView addSubview:self.InfoImage];

        UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapToWed)];
        [self.InfoImage addGestureRecognizer:tap1];
        
    }
}





//设置公告轮滑
- (void)setScrollView {
//    [self.scView removeFromSuperview];
    if (_isLogin == NO) {
        
        //广告轮播背景
//            UIImageView * baImag = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0 * kscale, kScreenW , 168 * kscaleW)];
//            baImag.image = [UIImage imageNamed:@"banner"];
//            [_backView addSubview:baImag];
        self.scView = [[ScrollView alloc] initWithFrame:CGRectMake(0, 0 * kscale, kScreenW , 168 * kscale)];
        [_backView addSubview:self.scView];
        //[UIApplication sharedApplication].keyWindow addSubview:
        //self.scView = scView;
        self.scView.currentPageTinColor = kColor_255_69_69;
        self.scView.isTireming= YES;
        self.scView.isPageControling = YES;
        self.scView.placeHolderImage = @"banner";
        self.scView.delegate = self;
        //    scView.currentPageTinColor = [UIColor darkGrayColor];
        //    scView.pageTinColor = [UIColor whiteColor];
        
//        [scView.imageUrlArray addObjectsFromArray:@[@"banner",@"banner"]];
        

    }
    else{
//        [self.scView removeFromSuperview];
        self.scView = [[ScrollView alloc] initWithFrame:CGRectMake(0, 90*kscale, kScreenW , 210 * kscale)];
        [_backView addSubview:self.scView];
        //self.scView = scView;
        self.scView.currentPageTinColor = kColor_255_69_69;
        self.scView.isTireming= YES;
        self.scView.isPageControling = YES;
        self.scView.placeHolderImage = @"banner";
        self.scView.delegate = self;
        //    scView.currentPageTinColor = [UIColor darkGrayColor];
        //    scView.pageTinColor = [UIColor whiteColor];
        
//        [scView.imageUrlArray addObjectsFromArray:@[@"banner",@"banner"]];
//        [scView reloadData];
    }
  
}
//设置下滑后6个按钮UI
- (void)setSixBtnUI
{
    UIImage *blackimage = [UIImage imageNamed:@"safety_bg"];
    UIImageView *blackView = [[UIImageView alloc] initWithImage:blackimage];
    blackView.frame = CGRectMake(0, kScreenH, kScreenW, kScreenH);
    blackView.userInteractionEnabled = YES;
//    blackView.backgroundColor = [UIColor blackColor];
    [_backView addSubview:blackView];
    
    //竖线
    UILabel *shuLine = [[UILabel alloc] initWithFrame:CGRectMake(kScreenW/2, 0, 1, LeftH*3)];
    shuLine.backgroundColor = LINECOLOR;
    [blackView addSubview:shuLine];
    
    UILabel *zeroLine = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenW, 2)];
    zeroLine.backgroundColor = LINECOLOR;
    [blackView addSubview:zeroLine];

    
    UILabel *oneLine = [[UILabel alloc] initWithFrame:CGRectMake(0, LeftH, kScreenW, 1)];
    oneLine.backgroundColor = LINECOLOR;
    [blackView addSubview:oneLine];
    
    UILabel *twoLine = [[UILabel alloc] initWithFrame:CGRectMake(0, LeftH*2, kScreenW, 1)];
    twoLine.backgroundColor = LINECOLOR;
    [blackView addSubview:twoLine];
    
    UILabel *threeLine = [[UILabel alloc] initWithFrame:CGRectMake(0, LeftH*3, kScreenW, 1)];
    threeLine.backgroundColor = LINECOLOR;
    [blackView addSubview:threeLine];
    
    
    
    
    
    //6个按钮
    UIButton *firstBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/4-85/2, (LeftH-75)/2, 85, 75)];

    firstBtn.tag = 1000;
    [firstBtn setBackgroundImage:[UIImage imageNamed:@"fengkonganquan"] forState:UIControlStateNormal];
    [blackView addSubview:firstBtn];
    
    UIButton *secondBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/2+(kScreenW/2-85)/2, (LeftH-75)/2, 85, 75)];
    secondBtn.tag = 1001;
    [secondBtn setBackgroundImage:[UIImage imageNamed:@"zijinanquan"] forState:UIControlStateNormal];
    [blackView addSubview:secondBtn];
    
    UIButton *thirdBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/4-85/2, LeftH+(LeftH-75)/2, 85, 75)];
    thirdBtn.tag = 1002;
    [thirdBtn setBackgroundImage:[UIImage imageNamed:@"yunyinganquan"] forState:UIControlStateNormal];
    [blackView addSubview:thirdBtn];
    
    UIButton *fourthBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/2+(kScreenW/2-85)/2, LeftH+(LeftH-75)/2, 85, 75)];
    fourthBtn.tag = 1003;
    [fourthBtn setBackgroundImage:[UIImage imageNamed:@"shujuanquan"] forState:UIControlStateNormal];
    [blackView addSubview:fourthBtn];
    
    UIButton *fifthBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/4-85/2, LeftH*2+(LeftH-75)/2, 85, 75)];
    fifthBtn.tag = 1004;
    [fifthBtn setBackgroundImage:[UIImage imageNamed:@"yinsianquan"] forState:UIControlStateNormal];
    [blackView addSubview:fifthBtn];
    
    UIButton *sixthBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenW/2+(kScreenW/2-85)/2, LeftH*2+(LeftH-75)/2, 85, 75)];
    sixthBtn.tag = 1005;
    [sixthBtn setBackgroundImage:[UIImage imageNamed:@"yewuanquan"] forState:UIControlStateNormal];
    [blackView addSubview:sixthBtn];
    
    //登录注册按钮
    UIButton *LoginBtn = [[UIButton alloc] initWithFrame:CGRectMake((kScreenW-205*kscale)/2, kScreenH - 180*kscale, 205*kscale , 40 * kscale)];
    [LoginBtn setBackgroundImage:[UIImage imageNamed:@"login"] forState:UIControlStateNormal];
    [LoginBtn addTarget:self action:@selector(loginBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [blackView addSubview:LoginBtn];
    
    
}
#pragma mark --点击方法
- (void)loginBtnClick
{
    XDLMLoginViewController *loginCtr = [[XDLMLoginViewController alloc] init];
    loginCtr.hidesBottomBarWhenPushed = YES;
    XDLMNavigatonController *nav = [[XDLMNavigatonController alloc] initWithRootViewController:loginCtr];
    
    [self presentViewController:nav animated:YES completion:nil];
}
//点击总资产
- (void)totalBtnClick
{
    XDAssetDetailsViewController *assetCtr = [[XDAssetDetailsViewController alloc] init];
    [self.navigationController pushViewController:assetCtr animated:YES];
}
//点击累计收益
- (void)accumulatedBtnClick
{
    XDLMTotalIncomeViewController *incomeCtr = [[XDLMTotalIncomeViewController alloc] init];
    [self.navigationController pushViewController:incomeCtr animated:YES];
}

//点击下边

-(void)tapToWed{
    XDLMMiiddleWebViewController *wed = [[XDLMMiiddleWebViewController alloc]init];
    wed.splitStr = @"yxjhapp.html";
    wed.titleStr = @"优选计划";
    [self.navigationController pushViewController:wed animated:YES];
}

//点击rightItem
- (void)RightTabbarItemClick
{
    
    XDPublicViewController *public = [[XDPublicViewController alloc] init];
    [self.navigationController pushViewController:public animated:YES];
    
}
#pragma mark --scrollImageDidDelegate
- (void)scrollImageDidDelegate:(NSInteger)count
{
    XDLMBannerInfoViewController *bannerInfo = [[XDLMBannerInfoViewController alloc] init];
    bannerInfo.count = count;
    bannerInfo.urlString = self.bannerDataSource[count];
    [self.navigationController pushViewController:bannerInfo animated:YES];
}
#pragma mark --辅助方法
//改变Label.Text后几位字符串大小
-(NSMutableAttributedString*) changeLabelWithText:(NSString*)needText
{
    
    NSMutableAttributedString *strAttribute = [[NSMutableAttributedString alloc] initWithString:_assetLab.text];
    [strAttribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:NSMakeRange(_assetLab.text.length - 3, 3)];
    return strAttribute;
}

-(void)viewDidLoad{
    [super viewDidLoad];
    
    self.process = [[XDLMMdShowProcess alloc]init];

   
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    NSUserDefaults *df = [NSUserDefaults standardUserDefaults];
    if ([df objectForKey:@"uid"]) {
        _isLogin = YES;
    }else _isLogin = NO;
    [self addview];
    self.tabBarController.tabBar.hidden=NO;
    self.navigationController.navigationBar.translucent = false;
    self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navtitlelogo"]];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationbar"] forBarMetrics:UIBarMetricsDefault];
    //    self.navigationController.navigationBarHidden = YES;
    [self loadBannerData];
    
}
//设置rightItem
- (void)setRightTabbarItem
{
//        _rightItem = [XDLMUIFactory createBBIWithImageStr:@"clock" target:self action:@selector(RightTabbarItemClick)];
//        self.navigationController.navigationItem.rightBarButtonItem = _rightItem;
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    btn.frame = CGRectMake(0, 0, 16, 18);
    UIImage *rigtimage = [[UIImage alloc]init];
    [btn addTarget:self action:@selector(RightTabbarItemClick) forControlEvents:UIControlEventTouchUpInside];
    NSInteger nowtime = [self getNowTimestamp];
    NSInteger newtime = [self timeSwitchTimestamp:self.ctTime andFormatter:@"YYYY-MM-dd HH:mm:ss"];
    NSUserDefaults *userDefaultes = [NSUserDefaults standardUserDefaults];
    NSString *myString = [userDefaultes stringForKey:@"mtTime"];
    if (myString.length == 0) {
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        [user setObject:self.ctTime forKey:@"mtTime"];
        [user synchronize];
        if (newtime > nowtime) {
            rigtimage = [UIImage imageNamed:@"redclock"];
        }else{
            rigtimage = [UIImage imageNamed:@"clock"];
        }
    }else{
        NSInteger bendi = [self timeSwitchTimestamp:myString andFormatter:@"YYYY-MM-dd HH:mm:ss"];
        if (bendi == newtime) {
            if ((nowtime - bendi)/(60 * 60 * 24) > 3) {
                rigtimage = [UIImage imageNamed:@"clock"];
            }else{
                rigtimage = [UIImage imageNamed:@"redclock"];
            }
        }else{
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            [user setObject:self.ctTime forKey:@"mtTime"];
            [user synchronize];
            rigtimage = [UIImage imageNamed:@"redclock"];
        }
    }
    
    
    [btn setBackgroundImage:rigtimage forState:UIControlStateNormal];
    
    UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithCustomView:btn];
    [self.navigationItem setRightBarButtonItem:bbi];

}

-(NSInteger)getNowTimestamp{
    
    
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    //设置时区,这个对于时间的处理有时很重要
    
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    
    [formatter setTimeZone:timeZone];
    
    NSDate *datenow = [NSDate date];//现在时间
    
    
    
    NSLog(@"设备当前的时间:%@",[formatter stringFromDate:datenow]);
    
    //时间转时间戳的方法:
    
    
    
    NSInteger timeSp = [[NSNumber numberWithDouble:[datenow timeIntervalSince1970]] integerValue];
    
    
    
    NSLog(@"设备当前的时间戳:%ld",(long)timeSp); //时间戳的值
    
    
    
    return timeSp;
    
}


-(NSInteger)timeSwitchTimestamp:(NSString *)formatTime andFormatter:(NSString *)format{
    
    
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:format]; //(@"YYYY-MM-dd hh:mm:ss") ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    
    
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    
    [formatter setTimeZone:timeZone];
    
    
    
    NSDate* date = [formatter dateFromString:formatTime]; //------------将字符串按formatter转成nsdate
    
    //时间转时间戳的方法:
    
    NSInteger timeSp = [[NSNumber numberWithDouble:[date timeIntervalSince1970]] integerValue];
    
    
    
    NSLog(@"将某个时间转化成 时间戳&&&&&&&timeSp:%ld",(long)timeSp); //时间戳的值
    
    
    
    return timeSp;
    
}
-(NSMutableArray *)bannerDataSource
{
    if (_bannerDataSource == nil) {
        _bannerDataSource = [[NSMutableArray alloc] init];
    }
    return _bannerDataSource;
}

@end
